/* 
 * This code is part of the smartlink project, see
 * 
 * 		http://code.google.com/p/smartlink/.
 * 
 * Copyright (C) 2008 Oliver Noelle
 * 
 * SmartLink is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * SmartLink is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with SmartLink.  If not, see <http://www.gnu.org/licenses/>.
 **/
package org.smartlink.search;

/**
 * fuzzysearch returns an array of <NoBestMatches> entries of this class beware
 * of null-pointers if checkNext is invoked less then <NoBestMatches> times! in
 * this case (eg only five streets in db), evaluate the returned array until the
 * first null-pointer! objPtr can be filled with anything when invoking
 * FuzzySearch.checkNext(...)
 */
public class BestMatchEntry {
	/**
	 * similarity coefficient, between 0(no match at all) and 1000 (all ngrams
	 * found)
	 */
	public int sim;
	/** original string description of the object */
	public String objName;
	/** preprocessed string description */
	public String preparedName;
	/** user-filled...whatever you like */
	public Object objPtr;

	public BestMatchEntry(int sim, String objName, String preparedName, Object objPtr) {
		this.sim = sim;
		this.objPtr = objPtr;

		// copy objName (if entry is too long, we simply cut it off to
		// MaximumEntryLength)
		this.objName = objName;
		// char* tmpPtr=objName;
		// for ( ; *objName_ && (tmpPtr-objName < MaximumEntryLength-1);
		// tmpPtr++, objName_++)
		// *tmpPtr=*objName_;
		// *tmpPtr='\0';

		// copy preparedName (shouldn't be too long because already cut off in
		// FuzzySearch::prepareString, but to be sure...)
		this.preparedName = preparedName;
		// tmpPtr=preparedName;
		// for ( ; *preparedName_ && (tmpPtr-preparedName <
		// MaximumEntryLength-1); tmpPtr++, preparedName_++)
		// *tmpPtr=*preparedName_;
		// *tmpPtr='\0';
	}
};
